import { Injectable } from '@nestjs/common'
import { CreateOtherDto } from './dto/create-other.dto'
import { UpdateOtherDto } from './dto/update-other.dto'
import { PrismaService } from 'src/prisma/prisma.service'

@Injectable()
export class OtherService {
  constructor(private prisma: PrismaService) {}
  create(createOtherDto: CreateOtherDto) {
    return this.prisma.other.create({ data: createOtherDto })
  }

  async findAll(args: Record<string, any> = {}) {
    const { sectionId } = args
    return await this.prisma.other.findMany({ where: { sectionId: +sectionId } })
  }

  findOne(id: number) {
    return `This action returns a #${id} other`
  }

  update(id: number, updateOtherDto: UpdateOtherDto) {
    return `This action updates a #${id} other`
  }

  remove(id: number) {
    return `This action removes a #${id} other`
  }

  async removeAll(id: number) {
    return await this.prisma.other.deleteMany({ where: { sectionId: id } })
  }
}
